﻿@inject IDataCacheService _dataCacheService


@if (Model.ChildEntriesState == EditState.Preview)
{
    <CnGalWebSite.Shared.MasaComponent.Shared.Editors.Buttons.RevokeButton Url="@("/tags/EditChildEntries/" + Model.Id)" ExamineType="Operation.EditTagChildEntries" OnClickRevoke="OnClickRevoke" />
}
<CnGalWebSite.Components.Containers.MasaTitleContainer Title="子词条" Icon="@IconType.Entry.ToIconString()" Collapable Outline>
    <div class="row">
        @foreach (var item in Model.ChildrenEntries.Skip((Model.CurrentPage - 1) * MaxCount).Take(MaxCount))
        {
            <div class="@(ForceSmall?"col-12 col-md-6 mb-3":"col-12 col-sm-6 col-md-4 col-lg-3 mb-3")">
                <TagChildEntryInforTip Model="item" />
            </div>
        }
        @if (TotalPages > 1)
        {
            <div class="col-12">
                <CnGalWebSite.Components.Paginations.MasaPagination Value="@Model.CurrentPage" Length="@TotalPages" ValueChanged="OnPageClick"/>

            </div>
        }
    </div>

</CnGalWebSite.Components.Containers.MasaTitleContainer>

@code {
    [Parameter]
    public TagIndexViewModel Model { get; set; } = new TagIndexViewModel();
    [Parameter]
    public EventCallback<Operation> OnClickRevoke { get; set; }
    [Parameter]
    public bool ForceSmall { get; set; }

    public int MaxCount { get; set; } = 24;

    public int TotalPages => ((Model.ChildrenEntries.Count - 1) / MaxCount) + 1;

    private void OnPageClick(int pageIndex)
    {
        Model.CurrentPage = pageIndex;

        StateHasChanged();

        
    }
}
